package com.ruoyi.controller;

import com.ruoyi.entity.MessageRequest;
import com.ruoyi.entity.MessageResponse;
import com.ruoyi.feign.NtfyServiceClient;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/ntfy/push")
@Slf4j
public class PushController {

    @Autowired(required = false)
    private NtfyServiceClient ntfyServiceClient;
    
    @PostMapping("/weather")
    public ResponseEntity<MessageResponse> sendNTFPMessage(@RequestBody MessageRequest request) {

        log.info("getRealtimeTemperature,request:{}",request);
        MessageResponse result = ntfyServiceClient.sendNtfyMessage(request);
        log.info("message response,{}",result.toString());
        return ResponseEntity.ok(result);
    }
}